// 导入 Vue 和 Vue Router
import Vue from "vue";
import VueRouter from "vue-router";
//  创建一个新的路由实例
Vue.use(VueRouter);

const router = new VueRouter({
    mode: 'hash', // 使用 hash 模式
    routes: [
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: '/login',
            name: 'Login',
            component: () => import('../views/Login.vue')
        },
        {
            path: '/home',
            name: 'Home',
            component: () => import('../views/Home.vue'),
            // 重定向到欢迎页面
            redirect: '/selfInfo',
            children: [
                {
                    path: '/welcome',
                    name: 'Welcome',
                    component: () => import('../views/WelcomePage.vue')
                },
                {
                    path: '/roles',
                    name: 'Roles',
                    component: () => import('../views/Role.vue')
                },
                {
                    path: '/selfInfo',
                    name: 'Selfinfo',
                    component: () => import('../views/SelfInfo.vue')
                },
                {
                    path: '/users',
                    name: 'Users',
                    component: () => import('../views/User.vue')
                },
            ]
        },
    ]
});

export default router;